
AddCSLuaFile( "shared.lua" )//Here is where we'll define all the shared traits of the SWEP

SWEP.Author			= "Clock"
SWEP.Contact		= ""
SWEP.Purpose		= "Control where players spawn"
SWEP.Instructions	= "Left click to create new spawn point. \n Right click to remove spawn point."

SWEP.ViewModelFOV	= 62
SWEP.ViewModelFlip	= false
SWEP.ViewModel		= "models/weapons/v_toolgun.mdl"
SWEP.WorldModel		= "models/weapons/w_toolgun.mdl"
SWEP.AnimPrefix		= "python"

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= false

SWEP.Primary.ClipSize		= -1				
SWEP.Primary.DefaultClip	= -1				
SWEP.Primary.Automatic		= false				
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize 	= -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic 	= false
SWEP.Secondary.Ammo 		= "none"


function SWEP:Initialize()

	local spawnPointsRaw = {}
	spawnPoints = {}

	local dataRaw = file.Read("BizarreBazaar/SpawnPoints.txt")
	local data = string.Left(dataRaw,string.len(dataRaw) -1)
	local spawnPointsRaw = string.Explode(";",data)
	
		for k,v in ipairs(spawnPointsRaw) do
				vectorTable = string.Explode(",",v)
				local newVector = Vector(tonumber(vectorTable[1]),tonumber(vectorTable[2]), tonumber(vectorTable[3]))
				table.insert(spawnPoints, newVector)
		end
	timer.Simple(1, self.SendSpawnPoints, self)
end

function SWEP:Deploy()
	return true;
end

function SWEP:SendSpawnPoints()
	for k,v in ipairs(spawnPoints) do

		umsg.Start("SpawnPoint")
			umsg.Vector(v)
		umsg.End()
	
	end
end


function SWEP:Reload() 
end



function SWEP:Think()	
end


function SWEP:PrimaryAttack()

	 trace = util.GetPlayerTrace(self.owner) //Get a player's trace table
	 traceRes = util.TraceLine(trace) //Actually perform the trace (apparently this is something that needs to be done?)
	 hitVector = traceRes.HitPos
	 local xComponent,yComponent,zComponent = tostring(hitVector.x), tostring(hitVector.y), tostring(hitVector.z) //Resolve the vector into string components
	 file.Append("BizarreBazaar/SpawnPoints.txt", xComponent..","..yComponent..","..zComponent..";") //Write the components to a data file
	
end


function SWEP:SecondaryAttack() //Nothing for now.

	
end